<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Conexao com o BD - Parte 2</title>
		<%	
			String driver = "net.sourceforge.jtds.jdbc.Driver";
			String url = "jdbc:jtds:sqlserver:/10.4.0.89:1433/bdtecwebmanhaIgrupo07";
			String user = "bdtecwebmanhaIgrupo07";
			String pass = "123456";
			String vnome = "'"+request.getParameter("txtnome")+"'";
			String vemail = "'"+request.getParameter("txtemail")+"'";
			out.print("Nome: "+vnome);
			out.print("Email: "+vemail);
			
			try{
				Class.forName(driver);
				Connection conn = DriverManager.getConnection(url,user,pass);
				Statement stm = conn.createStatement();
				String query = "insert into alunos_k (nome,email) values("+vnome+","+vemail+")";
				stm.execute(query);
				conn.commit();
				conn.close();
				out.println("Gravado com Sucesso");
			}catch(Exception e){
				out.println("Erro ao Gravar ");
			}
				
		%>
	</head>
	<body>
		
	</body>
</html>